package com.le.tester.book.concurrentjavafight.l7_2_3;

import java.io.File;
import java.io.FileFilter;
import java.util.concurrent.BlockingQueue;

/**
 * createTime：2022/11/18 9:59
 * description：通过"毒丸"对象来关闭服务,
 * 仅在知道生产者数量和消费者数量的情况才可以有效的使用,
 * 那么数量的形式那就得考虑数量得大小多方法效率得影响了
 */
public class IndexingService {

    private static final File POISON = new File("");

    private final IndexThread consumer = new IndexThread();

    private final CrawlerThread product = new CrawlerThread();

    private final BlockingQueue<File> queue;

    private final FileFilter fileFilter;

    private final File root;

    public IndexingService(BlockingQueue<File> queue, FileFilter fileFilter, File root) {
        this.queue = queue;
        this.fileFilter = fileFilter;
        this.root = root;
    }

    class CrawlerThread extends Thread {
    }

    class IndexThread extends Thread {
    }

    public void start() {
        product.start();
        consumer.start();
    }

    public void stop() {
        product.interrupt();
    }

    public void awaitTermination() throws InterruptedException {
        consumer.join();
    }
}


